//
//  NThemDetailHeadView.m
//  News
//
//  Created by zhangtao on 2018/10/15.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "NThemDetailHeadView.h"

@implementation NThemDetailHeadView
{
    UIButton *selectBtn;
}

-(void)awakeFromNib{
    [super awakeFromNib];
    selectBtn = self.nearBtn;
}

-(void)setTopicalModel:(NTopicalModel *)topicalModel{
    [_coverPic sd_setImageWithURL:[NSURL URLWithString:topicalModel.CoverPic] placeholderImage:default_max_img];
    _nameLab.text = topicalModel.TopicalName;
    _articleNumLab.text = [NSString stringWithFormat:@"%@", topicalModel.ArticleNum];
    _followNumLab.text = [NSString stringWithFormat:@"%@", topicalModel.FollowNum];
    _abstractLab.text = topicalModel.Abstract;
}

- (IBAction)click:(UIButton *)sender {
    NSInteger tag = sender.tag;
    if (tag == theme_focus) {
        sender.selected = !sender.selected;
    }
    if (tag<3) {
        if (sender == selectBtn) {
            return;
        }
        
        sender.selected = YES;
        selectBtn.selected = NO;
        selectBtn = sender;
        
        _bottomMarkLab.frame = CGRectMake(sender.frame.origin.x, _bottomMarkLab.frame.origin.y, sender.frame.size.width, 2);
    }
    
    if (self.themeDetailHeadCallBack) {
        self.themeDetailHeadCallBack(tag);
    }
    
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    _focusBtn.layer.cornerRadius = 4;
    _focusBtn.layer.borderWidth = 1;
    _focusBtn.layer.borderColor = MAIN_COLOR.CGColor;
}


@end
